package view;

import java.awt.GridBagConstraints;
import java.awt.Insets;

/**
 * Utility-class to create GridBagConstraints-objects
 */
public abstract class GBCUtils {

    /**
     * Returns a GridBagConstraints-object with the committed specifications.
     * 
     * @param xPos
     *            x-position
     * @param yPos
     *            y-position
     * @param columnCount
     *            column-count
     * @param rowCount
     *            row-count
     * @param extraHorSpace
     *            extra horizontal space ( 0.0 to 1.0 )
     * @param extraVerSpace
     *            extra vertical space ( 0.0 to 1.0 )
     * @param fillExtraSpace
     *            how to fill extra space ( horizontal, vertical, both )
     * @param padding
     *            external padding ( top, left, bottom, right )
     * @return a GridBagConstraints-object with the committed specifications
     */
    public static GridBagConstraints getGBC( int xPos, int yPos, int columnCount, int rowCount, double extraHorSpace,
	    double extraVerSpace, int fillExtraSpace, Insets padding )
    {
	GridBagConstraints gbc = new GridBagConstraints();
	gbc.gridx = xPos;
	gbc.gridy = yPos;
	gbc.gridwidth = columnCount;
	gbc.gridheight = rowCount;
	gbc.weightx = extraHorSpace;
	gbc.weighty = extraVerSpace;
	gbc.fill = fillExtraSpace;

	if ( padding != null )
	{
	    gbc.insets = padding;
	}
	return gbc;
    }

    /**
     * Returns a GridBagConstraints-object with the committed specifications.
     * 
     * @param xPos
     *            x-position
     * @param yPos
     *            y-position
     * @param columnCount
     *            column-count
     * @param rowCount
     *            row-count
     * @param fillExtraSpace
     *            how to fill extra space ( horizontal, vertical, both )
     * @param padding
     *            external padding ( top, left, bottom, right )
     * @return a GridBagConstraints-object with the committed specifications
     */
    public static GridBagConstraints getGBC( int xPos, int yPos, int columnCount, int rowCount, int fillExtraSpace,
	    Insets padding )
    {
	return getGBC( xPos, yPos, columnCount, rowCount, 0.0, 0.0, fillExtraSpace, padding );
    }

    /**
     * Returns a GridBagConstraints-object with the committed specifications.
     * 
     * @param xPos
     *            x-position
     * @param yPos
     *            y-position
     * @param columnCount
     *            column-count
     * @param rowCount
     *            row-count
     * @param fillExtraSpace
     *            how to fill extra space ( horizontal, vertical, both )
     * @return a GridBagConstraints-object with the committed specifications
     */
    public static GridBagConstraints getGBC( int xPos, int yPos, int columnCount, int rowCount, int fillExtraSpace )
    {
	return getGBC( xPos, yPos, columnCount, rowCount, 0.0, 0.0, fillExtraSpace, null );
    }

    /**
     * Returns a GridBagConstraints-object with the committed specifications.
     * 
     * @param xPos
     *            x-position
     * @param yPos
     *            y-position
     * @param columnCount
     *            column-count
     * @param rowCount
     *            row-count
     * @param padding
     *            external padding ( top, left, bottom, right )
     * @return a GridBagConstraints-object with the committed specifications
     */
    public static GridBagConstraints getGBC( int xPos, int yPos, int columnCount, int rowCount, Insets padding )
    {
	return getGBC( xPos, yPos, columnCount, rowCount, 0.0, 0.0, GridBagConstraints.NONE, padding );
    }

    /**
     * Returns a GridBagConstraints-object with the committed specifications.
     * 
     * @param xPos
     *            x-position
     * @param yPos
     *            y-position
     * @param columnCount
     *            column-count
     * @param rowCount
     *            row-count
     * @param extraHorSpace
     *            extra horizontal space (0.0 to 1.0 )
     * @param extraVerSpace
     *            extra vertical space ( 0.0 to 1.0 )
     * @param padding
     *            external padding ( top, left, bottom, right )
     * @return a GridBagConstraints-object with the committed specifications
     */
    public static GridBagConstraints getGBC( int xPos, int yPos, int columnCount, int rowCount, double extraHorSpace,
	    double extraVerSpace, Insets padding )
    {
	return getGBC( xPos, yPos, columnCount, rowCount, extraHorSpace, extraVerSpace, GridBagConstraints.NONE,
		padding );
    }

    /**
     * Returns a GridBagConstraints-object with the committed specifications.
     * 
     * @param xPos
     *            x-position
     * @param yPos
     *            y-position
     * @param columnCount
     *            column-count
     * @param rowCount
     *            row-count
     * @param extraHorSpace
     *            extra horizontal space ( 0.0 to 1.0 )
     * @param extraVerSpace
     *            extra vertical space ( 0.0 to 1.0 )
     * @param fillExtraSpace
     *            how to fill extra space ( horizontal, vertical, both )
     * @return a GridBagConstraints-object with the committed specifications
     */
    public static GridBagConstraints getGBC( int xPos, int yPos, int columnCount, int rowCount, double extraHorSpace,
	    double extraVerSpace, int fillExtraSpace )
    {
	return getGBC( xPos, yPos, columnCount, rowCount, extraHorSpace, extraVerSpace, fillExtraSpace, null );
    }

    /**
     * Returns a GridBagConstraints-object with the committed specifications.
     * 
     * @param xPos
     *            x-position
     * @param yPos
     *            y-position
     * @param columnCount
     *            column-count
     * @param rowCount
     *            row-count
     * @param extraHorSpace
     *            extra horizontal space ( 0.0 to 1.0 )
     * @param extraVerSpace
     *            extra vertical space ( 0.0 to 1.0 )
     * @return a GridBagConstraints-object with the committed specifications
     */
    public static GridBagConstraints getGBC( int xPos, int yPos, int columnCount, int rowCount, double extraHorSpace,
	    double extraVerSpace )
    {
	return getGBC( xPos, yPos, columnCount, rowCount, extraHorSpace, extraVerSpace, GridBagConstraints.NONE, null );
    }

    /**
     * Returns a GridBagConstraints-object with the committed specifications.
     * 
     * @param xPos
     *            x-position
     * @param yPos
     *            y-position
     * @param columnCount
     *            column-count
     * @param rowCount
     *            row-count
     * @return a GridBagConstraints-object with the committed specifications
     */
    public static GridBagConstraints getGBC( int xPos, int yPos, int columnCount, int rowCount )
    {
	return getGBC( xPos, yPos, columnCount, rowCount, 0.0, 0.0, GridBagConstraints.NONE, null );
    }
}